﻿#region itdc

/************************************************************************
*Copyright(C) 2015 by qsgy
 *All rights reserved. 
 *FileName:     $safeitemname$
 *Author:       oyh
 *Version:      
 *UnityVersion：
 *Date:   $time$      
 *Description:    
 *History: 
************************************************************************/
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 时间状态
/// 状态在该条件下持续一段时间
/// </summary>
public class TimerTransition : Transition
{
    [Tooltip("状态持续时间")]
    public float due = 3f;
    bool arrived = false;
    public TimerTransition()
    {
        id = TransitionID.Timer;
    }
    public override bool IsTransition()
    {

        return arrived;
    }
    //激活时开始计时
    public override void Enter()
    {
        StartCoroutine(CountTime());
    }

    //退出时重置
    public override void Exit()
    {
        StopCoroutine("CountTime");
        arrived = false;
    }
    private void OnEnable()
    {
        StopCoroutine("CountTime");

    }

    //到时间将输出设置为true
    private IEnumerator CountTime()
    {
        yield return new WaitForSeconds(due);
        arrived = true;
    }
}
